/**
 * Created by Administrator on 2017/4/30.
 */
var speed = 30;
function show() {
	var elementById = document.getElementById("moveobj");
	if (elementById.style.display == "block") {
		elementById.style.display = "none";
	} else {
		elementById.style.display = "block";
	}
}
function changebig() {
	var elementById = document.getElementById("moveobj");
	// console.log(elementById.clientWidth);sf  , 你 闺女hbb,你   ,  l,/,哭了.
	if (elementById.style.width=="") {
		elementById.style.width = "100px";
		elementById.style.height = elementById.style.width;

	} else {
		var s = elementById.style.width.substr(0,elementById.style.width.length-2);
		elementById.style.width = parseInt(s) + speed + "px";
		elementById.style.height = elementById.style.width;
	}

}
function changesmall() {
	var elementById = document.getElementById("moveobj");
	console.log(elementById.clientWidth);
	if (elementById.style.width=="") {
		elementById.style.width = "100px";
		elementById.style.height = elementById.style.width;

	} else {
		elementById.style.width = parseInt(elementById.style.width.substr(0,elementById.style.width.length-2)) - speed + "px";
		elementById.style.height = elementById.style.width;
	}

}
function maveright() {
	var elementById = document.getElementById("moveobj");
	console.log(elementById.clientWidth);
	if (elementById.style.marginLeft=="") {
		elementById.style.marginLeft = "0px";

	} else {
		elementById.style.marginLeft = parseInt(elementById.style.marginLeft.substr(0,elementById.style.marginLeft.length-2)) + speed + "px";
	}

}
function maveleft() {
	var elementById = document.getElementById("moveobj");
	console.log(elementById.clientWidth);
	if (elementById.style.marginLeft=="") {
		elementById.style.marginLeft = "0px";

	} else {
		elementById.style.marginLeft = parseInt(elementById.style.marginLeft.substr(0,elementById.style.marginLeft.length-2)) - speed + "px";
	}

}
function mavedown() {
	var elementById = document.getElementById("moveobj");
	console.log(elementById.clientWidth);
	if (elementById.style.marginTop=="") {
		elementById.style.marginTop = "0px";

	} else {
		elementById.style.marginTop = parseInt(elementById.style.marginTop.substr(0,elementById.style.marginTop.length-2)) + speed + "px";
	}

}
function maveUp() {
	var elementById = document.getElementById("moveobj");
	console.log(elementById.clientWidth);
	if (elementById.style.marginTop=="") {
		elementById.style.marginTop = "0px";

	} else {
		elementById.style.marginTop = parseInt(elementById.style.marginTop.substr(0,elementById.style.marginTop.length-2)) - speed + "px";
	}

}
function move(e) {
	var keynum = e.keyCode;
	console.log(keynum);
	if(keynum==119) {
		maveUp();
	}else if (keynum==115){
		mavedown();
	}else if (keynum==97){
		maveleft();
	}else if (keynum==100){
		maveright();
	}


}